package com.geostar.constructionland.common.mapper.biz;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.geostar.constructionland.common.entity.biz.PieceLandInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author yelll
 * @since 2020-6-12 14:40
 **/
public interface PieceLandInfoMapper extends BaseMapper<PieceLandInfo> {
    /**
     * 根据业务ID获取地块信息
     * @param ywid
     * @return
     */
    @Select("select dkid,dkbh,dkmc,dkmj,dkyt,tfh,jzds,kcdjid,xh,dkmj_ys,yzgeojson,sfsjsd,dksx from jsyd_dkxx where kcdjid in (select kcdjid from jsyd_xmdkgx where ywid=#{ywid})")
    List<PieceLandInfo> getPieLandInfosByYwid(@Param("ywid")String ywid);

    @Update("<script>" +
            "<foreach collection='pieceLands' item='pieceLand' index='index' open='begin' close=';end;' separator=';'>"+
            " update jsyd_dkxx "+
            " set dkmj = 0 , dkmj_ys = #{pieceLand.dkmj,jdbcType=NUMERIC} "+
            " where dkid = #{pieceLand.dkid,jdbcType=VARCHAR} "+
            "</foreach>"+
            "</script>")
    int updatePieceLandZymjBatch(@Param("pieceLands") List<PieceLandInfo> pieceLandInfoList);


    @Update(" update jsyd_dkxx t set t.dkmj = #{dkmj} where t.dkid = #{dkid} ")
    void updateAdjustDkmj(@Param("dkid")String dkid,@Param("dkmj")double dkmj);
}
